package org.example.reference;

import java.lang.ref.WeakReference;

public class T03_WeakReference {
    public static void main(String[] args) {
        WeakReference<M> m = new WeakReference<>(new M());
        System.out.println(m.get());
        System.gc();
        System.out.println(m.get());

        ThreadLocal<M> tl = new ThreadLocal<>(); // 填充的变量属于当前线程，对其他线程而言是隔离的
        tl.set(new M());
        tl.remove();
    }
}
